//package com.mrzhou.rabbit.service.impl;
//
//import com.mrzhou.rabbit.entity.EsMqMessage;
//import com.mrzhou.rabbit.entity.User;
//import com.mrzhou.rabbit.repository.UserRepository;
//import com.mrzhou.rabbit.service.IElasticsearchService;
//import com.mrzhou.web.util.FileUtil;
//import lombok.SneakyThrows;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.core.io.Resource;
//import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
//import org.springframework.data.elasticsearch.core.IndexOperations;
//import org.springframework.data.elasticsearch.core.document.Document;
//import org.springframework.stereotype.Service;
//
//import java.io.BufferedReader;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.util.Map;
//import java.util.StringJoiner;
//
///**
// * @author qiang.zhou
// */
//@Service
//public class ElasticsearchServiceImpl implements IElasticsearchService {
//
//    @Autowired
//    private ElasticsearchRestTemplate elasticsearchRestTemplate;
//
//    @Override
//    @SneakyThrows
//    public <T> void createIndex(Class<T> clazz) {
//        String jsonSetting = FileUtil.loadSetting("es-settings/elasticsearch.json");
//        // 创建索引并设置配置
//        IndexOperations operations = elasticsearchRestTemplate.indexOps(clazz);
//        boolean flag = operations.create(Document.parse(jsonSetting));
//        if(flag) {
//            // 设置索引的映射规则
//            operations.putMapping(operations.createMapping(clazz));
//            return;
//        }
//        throw new Exception("Elasticsearch索引创建失败");
//    }
//
//
//}
